package com.huashi.dealer.commonEntity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 订单退款实体类
 */
@Getter
@Setter
@Schema(description = "订单退款实体")
public class OrderRefund {

    @TableId(value = "refund_id", type = IdType.AUTO)
    @Schema(description = "退款ID")
    private Long refundId;

    @TableField("order_id")
    @Schema(description = "订单ID")
    private Long orderId;

    @TableField("order_goods_id")
    @Schema(description = "订单商品ID")
    private Long orderGoodsId;

    @TableField("user_id")
    @Schema(description = "用户ID")
    private Long userId;

    @TableField("type")
    @Schema(description = "退款类型：10退货退款，20换货")
    private Integer type;

    @TableField("is_agree")
    @Schema(description = "商家是否同意退款：0待审核，10已同意，20已拒绝")
    private Integer isAgree;

    @TableField("status")
    @Schema(description = "退款单状态：0进行中，10已拒绝，20已完成，30已取消")
    private Integer status;

    @TableField("refund_money")
    @Schema(description = "退款金额")
    private BigDecimal refundMoney;

    @TableField("refund_reason")
    @Schema(description = "退款原因")
    private String refundReason;

    @TableField("refund_desc")
    @Schema(description = "退款说明")
    private String refundDesc;

    @TableField("express_id")
    @Schema(description = "物流公司ID")
    private Integer expressId;

    @TableField("express_no")
    @Schema(description = "物流单号")
    private String expressNo;

    @TableField("is_delete")
    @TableLogic
    @Schema(description = "软删除标记")
    private Integer isDelete;

    @TableField("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "创建时间")
    private Long createTime;

    @TableField("update_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "更新时间")
    private Long updateTime;

    @TableField("agree_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "同意时间")
    private Long agreeTime;

    @TableField("refuse_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "拒绝时间")
    private Long refuseTime;

    @TableField("complete_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "完成时间")
    private Long completeTime;

    /**
     * 获取退款类型文本
     */
    @JsonProperty("typeText")
    public String getTypeText() {
        switch (type) {
            case 10: return "退货退款";
            case 20: return "换货";
            default: return "";
        }
    }

    /**
     * 获取商家是否同意退款文本
     */
    @JsonProperty("isAgreeText")
    public String getIsAgreeText() {
        switch (isAgree) {
            case 0: return "待审核";
            case 10: return "已同意";
            case 20: return "已拒绝";
            default: return "";
        }
    }

    /**
     * 获取退款单状态文本
     */
    @JsonProperty("statusText")
    public String getStatusText() {
        switch (status) {
            case 0: return "进行中";
            case 10: return "已拒绝";
            case 20: return "已完成";
            case 30: return "已取消";
            default: return "";
        }
    }
} 